﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RazakiBLL;
using RazakiBLL.Managers;

namespace RazakiSite.PagesNews
{
    public partial class NewsList : BasePage
    {
        UowRazaki _uowRazaki = new UowRazaki();

        private short ParentId
        {
            get { return UtilitiesUI.GetQueryString<short>("parentid", false); }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if ((_uowRazaki.NewTagRepository.GetMinoosoftFirstParentNewTag().Id == ParentId) && !UtilitiesUI.IsAdmin())
            {
                Response.Redirect("~");
            }

            if (IsPostBack)
                return;

            ConfigControls();
        }

        protected override void ConfigControls()
        {
            var newsList = _uowRazaki.NewRepository.GetAllByFirstParentId(_uowRazaki.NewTagRepository, ParentId);

            UCNewsList.Data = newsList;
        }
    }
}